package com.ss.android.article.base.feature.model;

import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Pair;

import com.bytedance.common.utility.Logger;
import com.bytedance.common.utility.NetworkType;
import com.ss.android.account.model.SpipeUser;
import com.ss.android.action.a.a.Comment;
import com.ss.android.article.base.feature.video.cache.VideoCacheController;
import com.ss.android.article.common.share.interf.IShareArticleBean;
import com.ss.android.b.a.BaseAdsData;
import com.ss.android.common.AbsApiThread;
import com.ss.android.common.util.json.CacheMember;
import com.ss.android.common.util.json.JsonParseListener;
import com.ss.android.common.util.json.JsonSerializable;
import com.ss.android.common.util.json.KeyName;
import com.ss.android.image.model.ImageInfo;
import com.ss.android.model.AbsArticle;
import com.ss.android.model.ItemType;
import com.ss.android.newmedia.BaseAppData;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

@CacheMember
public class Article extends AbsArticle implements IShareArticleBean, JsonParseListener, JsonSerializable {
    public final class a {
        public int tip;
        public long adId;
        public String adLabel;
        public String d;
        public List adTrackUrl;
        public String f;
        public List adClickTrackUrlList;
        public int[] title;
        public int[] _abstract;
        public long goDetailCount;
        public String label;
        public int labelStyle;
    }

    @KeyName(value = "article_sub_type")
    public int articleSubType;
    @KeyName(value = "article_url")
    public String articleUrl;
    @KeyName(value = "article_alt_url")
    public String articleAltUrl;
    @KeyName(value = "display_url")
    public String displayUrl;
    @KeyName(value = "display_title")
    public String displayTitle;
    @KeyName(value = "preload_web")
    public int preloadWeb;
    @KeyName(value = "group_type")
    public int groupType;
    @KeyName(value = "subject_label")
    public String subjectLabel;
    @KeyName(value = "item_version")
    public long itemVersion;
    @KeyName(value = "subject_group_id")
    public long subjectGroupId;
    public boolean delete;
    public boolean isDetailLoaded;
    public long webTypeLoadTime;
    public long N;
    public long webTcLoadTime;
    @KeyName(value = "natant_level")
    public int natantLevel;
    @KeyName(value = "group_flags")
    public int groupFlags;
    @KeyName(value = "tc_head_text")
    public String tcHeadText;
    @KeyName(value = "open_url")
    public String openUrl;
    @KeyName(value = "video_id")
    public String videoId;
    public boolean directPlay;
    public int videoWatchCount;
    public boolean showPgcSubscribe;
    public long videoSubjectId;
    public int videoType;
    public ImageInfo mLoadingCoverImageInfo;
    @KeyName(value = "source")
    public String source;
    @KeyName(value = "entity_scheme")
    public String entityScheme;
    @KeyName(value = "tiny_toutiao_url")
    public String tinyToutiaoUrl;
    @KeyName(value = "concern_id")
    public long concernId;
    @KeyName(value = "wap_headers")
    public JSONObject wapHeaders;
    @KeyName(value = "ignore_web_transform")
    public boolean ignoreWebTransform;
    public BaseAdsData aF;
    public String aG;
    public Pair<String, Long> videoPlayInfo;
    public String videoDetailInfo;
    @KeyName(value = "is_original")
    public boolean isOriginal;
    @KeyName(value = "video_duration")
    public int videoDuration;
    @KeyName(value = "ad_video_click_track_urls")
    public List adVideoClickTrackUrls;
    public String adVideoClickTrackUrlsJson;
    @KeyName(value = "tags")
    public List tags;
    @KeyName(value = "media_name")
    public String mediaName;
    public boolean ah;
    public String largeImageJson;
    public String middleImageJson;
    public String commentJson;
    @KeyName(value = "outer_schema")
    public String outerSchema;
    @KeyName(value = "open_page_url")
    public String openPageUrl;
    public String extJson;
    @Deprecated
    public a ao;
    @KeyName(value = "reason")
    public String reason;
    @KeyName(value = "gallary_image_count")
    public int gallaryImageCount;
    @KeyName(value = "gallary_flag")
    public int gallaryFlag;
    @KeyName(value = "reback_flag")
    @Deprecated
    public int rebackFlag;
    @KeyName(value = "entity_style")
    public int entityStyle;
    @KeyName(value = "entity_id")
    public long entityId;
    @KeyName(value = "entity_word")
    public String entityWord;
    @KeyName(value = "entity_text")
    public String entityText;
    @KeyName(value = "entity_mark")
    public int[] entityMark;
    public String entityMarkJson;
    @KeyName(value = "entity_followed")
    public int entityFollowed;
    @KeyName(value = "title")
    public String title;
    private int videoPreloadingFlag;
    @KeyName(value = "url")
    public String url;
    @KeyName(value = "city")
    public String city;
    @KeyName(value = "keywords")
    public String keywords;
    @KeyName(value = "publish_time")
    public long publishTime;
    @KeyName(value = "hot")
    public int hot;
    @KeyName(value = "has_video")
    public boolean hasVideo;
    @KeyName(value = "has_image")
    public boolean hasImage;
    @KeyName(value = "abstract")
    public String _abstract;
    public String imageList1;
    @KeyName(value = "image_list")
    public List imageList;
    @KeyName(value = "comment")
    public Comment comment;
    @KeyName(value = "comments")
    public List comments;
    public String commentsJson;
    @KeyName(value = "zzcomment")
    public List<Comment> zzcomment;
    public String zzcommentJson;
    @KeyName(value = "media_info")
    public MediaInfo mediaInfo;
    public String mediaInfoJson;
    @KeyName(value = "user_info")
    public UgcUser userInfo;
    public String userInfoJson;
    @KeyName(value = "media_user_id")
    public long mediaUserId;
    @KeyName(value = "large_image_list")
    public ImageInfo largeImageList;
    @KeyName(value = "middle_image")
    public ImageInfo middleImage;
    public List y;
    @KeyName(value = "article_type")
    public int articleType;

    public Article(long groupId, long itemId, int aggrType) {
        super(ItemType.ARTICLE, groupId, itemId, aggrType);
        this.imageList1 = "";
        this.preloadWeb = 0;
        this.groupType = 0;
        this.itemVersion = 0;
        this.subjectGroupId = 0;
        this.delete = false;
        this.isDetailLoaded = false;
        this.webTypeLoadTime = 0;
        this.N = 0;
        this.webTcLoadTime = 0;
        this.natantLevel = 0;
        this.groupFlags = 0;
        this.videoPreloadingFlag = 0;
        this.largeImageJson = "";
        this.middleImageJson = "";
        this.commentJson = "";
        this.ignoreWebTransform = true;
    }

    public final long getItemId() {
        return this.itemId;
    }

    public final int B() {
        return this.aggrType;
    }

    public final String getWendaEventName() {
        return "answer_detail";
    }

    public final int D() {
        return this.commentCount;
    }

    public final long getUserId() {
        long v0 = 0;
        if (this.mediaUserId != v0) {
            v0 = this.mediaUserId;
        } else {
            if (this.mediaInfo != null && this.mediaInfo.userId != v0) {
                return this.mediaInfo.userId;
            }

            if (this.userInfo != null && this.userInfo.user_id != v0) {
                return this.userInfo.user_id;
            }

            if (this.mediaInfo == null) {
                return v0;
            }

            if (this.mediaInfo.id == v0) {
                return v0;
            }

            v0 = this.mediaInfo.id;
        }

        return v0;
    }

    public final void a(Article article) {
        if (article != null && article != this) {
            if (article != null) {
                if (article.statsTimestamp > this.statsTimestamp) {
                    this.statsTimestamp = article.statsTimestamp;
                }

                this.level = ((AbsArticle) article).level;
                this.behotTime = ((AbsArticle) article).behotTime;
                this.shareUrl = ((AbsArticle) article).shareUrl;
                if (!this.userDigg && !((AbsArticle) this).userBury) {
                    this.userDigg = ((AbsArticle) article).userDigg;
                    this.userBury = ((AbsArticle) article).userBury;
                }

                if (this.buryCount < ((AbsArticle) article).buryCount) {
                    this.buryCount = ((AbsArticle) article).buryCount;
                }

                if (this.diggCount < ((AbsArticle) article).diggCount) {
                    this.diggCount = ((AbsArticle) article).diggCount;
                }

                if ((this.userDigg) && (((AbsArticle) this).userBury)) {
                    this.userBury = false;
                }

                if ((this.userDigg) && ((AbsArticle) this).diggCount <= 0) {
                    this.diggCount = 1;
                }

                if ((this.userBury) && ((AbsArticle) this).buryCount <= 0) {
                    this.buryCount = 1;
                }

                this.userLike = ((AbsArticle) article).userLike;
                if (this.likeCount < ((AbsArticle) article).likeCount) {
                    this.likeCount = ((AbsArticle) article).likeCount;
                }

                if ((((AbsArticle) this).userLike) && ((AbsArticle) this).likeCount <= 0) {
                    ((AbsArticle) this).likeCount = 1;
                }

                ((AbsArticle) this).repinCount = ((AbsArticle) article).repinCount;
                ((AbsArticle) this).commentCount = ((AbsArticle) article).commentCount;
                if (((AbsArticle) article).userDislike) {
                    ((AbsArticle) this).userDislike = ((AbsArticle) article).userDislike;
                }

                if (((AbsArticle) article).userRepin) {
                    ((AbsArticle) this).userRepin = ((AbsArticle) article).userRepin;
                    if (((AbsArticle) article).userRepinTime > 0) {
                        ((AbsArticle) this).userRepinTime = ((AbsArticle) article).userRepinTime;
                    }
                }

                if (((AbsArticle) this).clickTimestamp < ((AbsArticle) article).clickTimestamp) {
                    ((AbsArticle) this).clickTimestamp = ((AbsArticle) article).clickTimestamp;
                }

                if (((AbsArticle) this).impressionTimestamp >= ((AbsArticle) article).impressionTimestamp) {
                } else {
                    ((AbsArticle) this).impressionTimestamp = ((AbsArticle) article).impressionTimestamp;
                }
            }

            this.source = article.source;
            this.title = article.title;
            this.url = article.url;
            this.publishTime = article.publishTime;
            if (!android.support.design.a.isTextEmpty(article._abstract)) {
                this._abstract = article._abstract;
            }

            this.imageList = article.imageList;
            this.y = article.y;
            this.largeImageList = article.largeImageList;
            this.middleImage = article.middleImage;
            this.comment = article.comment;
            if (article.mBanComment) {
                this.mBanComment = article.mBanComment;
            }

            this.comments = article.comments;
            this.articleType = article.articleType;
            this.articleSubType = article.articleSubType;
            this.articleUrl = article.articleUrl;
            this.articleAltUrl = article.articleAltUrl;
            this.preloadWeb = article.preloadWeb;
            this.displayUrl = article.displayUrl;
            this.displayTitle = article.displayTitle;
            this.groupType = article.groupType;
            this.itemVersion = article.itemVersion;
            this.subjectGroupId = article.subjectGroupId;
            this.natantLevel = article.natantLevel;
            this.groupFlags = article.groupFlags;
            this.tcHeadText = article.tcHeadText;
            this.openUrl = article.openUrl;
            this.openPageUrl = article.openPageUrl;
            this.outerSchema = article.outerSchema;
            this.videoId = article.videoId;
            this.videoDuration = article.videoDuration;
            this.reason = article.reason;
            this.mediaName = article.mediaName;
            this.mediaInfoJson = article.mediaInfoJson;
            this.mediaInfo = article.mediaInfo;
            if (!android.support.design.a.isTextEmpty(article.userInfoJson)) {
                this.userInfoJson = article.userInfoJson;
            }

            if (article.userInfo != null) {
                this.userInfo = article.userInfo;
            }

            this.mediaUserId = article.mediaUserId;
            this.comments = article.comments;
            this.commentsJson = article.commentsJson;
            this.zzcomment = article.zzcomment;
            this.zzcommentJson = article.zzcommentJson;
            this.userLike = article.userLike;
            this.likeCount = article.likeCount;
            if (article.webTypeLoadTime > this.webTypeLoadTime) {
                this.webTypeLoadTime = article.webTypeLoadTime;
            }

            this.directPlay = article.directPlay;
            this.videoWatchCount = article.videoWatchCount;
            this.showPgcSubscribe = article.showPgcSubscribe;
            this.videoSubjectId = article.videoSubjectId;
            this.mLoadingCoverImageInfo = article.mLoadingCoverImageInfo;
            this.gallaryFlag = article.gallaryFlag;
            this.gallaryImageCount = article.gallaryImageCount;
            this.entityStyle = article.entityStyle;
            this.entityFollowed = article.entityFollowed;
            this.entityId = article.entityId;
            this.entityWord = article.entityWord;
            this.entityText = article.entityText;
            this.entityMark = article.entityMark;
            this.entityMarkJson = article.entityMarkJson;
            this.entityScheme = article.entityScheme;
            this.tinyToutiaoUrl = article.tinyToutiaoUrl;
            this.wapHeaders = article.wapHeaders;
            this.ignoreWebTransform = article.ignoreWebTransform;
            this.aF = article.aF;
            this.videoPlayInfo = article.videoPlayInfo;
        }
    }

    public final boolean a(long itemVersion) {
        return this.groupType == 1 && itemVersion != this.itemVersion;
    }

    public static int[] parseEntityMark(JSONArray arg10) throws JSONException {
        int[] v0 = null;
        if (arg10 != null && arg10.length() > 0) {
            int v7 = arg10.length();
            if (v7 <= 10) {
                int[] v1 = new int[v7 << 1];
                int v2 = 0;
                int v4 = 0;
                int v6 = 0;
                while (true) {
                    if (v2 < v7) {
                        JSONArray v5 = arg10.getJSONArray(v2);
                        if (v5.length() == 2) {
                            int v8 = v5.getInt(0);
                            int v5_1 = v5.getInt(1) + v8;
                            if (v8 >= v4 && v5_1 > v8) {
                                v1[v6] = v8;
                                v1[v6 + 1] = v5_1;
                                ++v2;
                                v6 += 2;
                                v4 = v5_1;
                                continue;
                            }
                        }
                    } else {
                        break;
                    }

                    return v0;
                }

                v0 = v1;
            }
        }

        return v0;
    }

    public static String a(long arg2, long arg4) {
        String v0 = arg4 > 0 ? "i_" + String.valueOf(arg4) : "g_" + String.valueOf(arg2);
        return v0;
    }

    public final boolean hasVideo() {
        return (!android.support.design.a.isTextEmpty(this.videoId))
                && this.mLoadingCoverImageInfo != null
                && this.mLoadingCoverImageInfo.mWidth > 0
                && this.mLoadingCoverImageInfo.mHeight > 0;
    }

    public static boolean a(int arg1) {
        boolean v0 = true;
        if (arg1 != 0 && arg1 != 1) {
            v0 = false;
        }

        return v0;
    }

    public final boolean shouldPreload(NetworkType networkType) {
        if ((this.hasArticleUrl())
                && (this.preloadWeb == 1 || this.preloadWeb == 2)
                && networkType != null
                && networkType != NetworkType.NONE
                && this.webTcLoadTime <= 0
                && (this.preloadWeb == 1 || networkType == NetworkType.WIFI)) {
            return true;
        }
        return false;
    }

    public final void initWithJO(JSONObject jo) {
        JSONArray v0_3;
        JSONObject v0;
        List v6 = null;
        int v2 = 0;
        super.initWithJO(jo);
        if (BaseAppData.inst().useOldParseJsonStyle()) {
            this.source = jo.optString("source");
            this.title = jo.optString("title");
            this.url = jo.optString("url");
            this.displayUrl = jo.optString("display_url");
            this.displayTitle = jo.optString("display_title");
            this.city = jo.optString("city");
            this.keywords = jo.optString("keywords");
            this.publishTime = jo.optLong("publish_time");
            this.hot = jo.optInt("hot");
            this.hasImage = jo.optBoolean("has_image");
            this.hasVideo = jo.optBoolean("has_video");
            this._abstract = jo.optString("abstract");
            this.gallaryImageCount = jo.optInt("gallary_image_count");
            this.gallaryFlag = jo.optInt("gallary_flag");
            JSONObject mediaInfo = jo.optJSONObject("media_info");
            this.mediaInfo = MediaInfo.fromJO(mediaInfo);
            if (this.mediaInfo != null) {
                this.mediaInfoJson = mediaInfo.toString();
            }

            JSONObject userInfo = jo.optJSONObject("user_info");
            this.userInfo = UgcUser.extractFromUserInfoJson(userInfo);
            if (this.userInfo != null) {
                this.userInfoJson = userInfo.toString();
            }

            this.mediaUserId = jo.optLong("media_user_id");
            this.imageList1 = "";
            this.imageList = v6;
            if (jo.has("image_list")) {
                try {
                    this.parseImageList(jo.optJSONArray("image_list"));
                } catch (Exception v0_1) {
                    Logger.v("Article", "parse image_list exception: " + v0_1);
                }
            }

            this.commentJson = "";
            this.comment = null;
            if (jo.has("comment")) {
                try {
                    JSONObject commentJO = jo.getJSONObject("comment");
                    this.parseComment(commentJO);
                    if (this.comment == null) {

                    } else {
                        this.commentJson = commentJO.toString();
                    }
                } catch (Exception e) {
                }
            }

            if (jo.has("comments")) {
                try {
                    this.setCommentsJSONArray(jo.getJSONArray("comments"));
                } catch (JSONException v0_2) {
                    Logger.throwExceptionInDebug(v0_2);
                }
            }

            this.largeImageJson = "";
            this.largeImageList = ((ImageInfo) v6);
            if (jo.has("large_image_list")) {
                try {
                    v0_3 = jo.getJSONArray("large_image_list");
                    if (v0_3.length() <= 0) {
                    } else {
                        this.largeImageList = ImageInfo.fromJson(v0_3.getJSONObject(0), true);
                        if (this.largeImageList == null) {
                        } else {
                            this.largeImageJson = v0_3.toString();
                        }
                    }
                } catch (Exception v0_1) {
                }
            }
            this.middleImageJson = "";
            this.middleImage = ((ImageInfo) v6);
            if (jo.has("middle_image")) {
                try {
                    userInfo = jo.getJSONObject("middle_image");
                    this.middleImage = ImageInfo.fromJson(userInfo, false);
                    if (this.middleImage == null) {
                    } else {
                        this.middleImageJson = userInfo.toString();
                    }
                } catch (Exception v0_1) {
                }
            }

            this.groupType = jo.optInt("group_type");
            this.subjectLabel = jo.optString("subject_label");
            this.itemVersion = jo.optLong("item_version");
            this.subjectGroupId = jo.optLong("subject_group_id");
            this.articleType = jo.optInt("article_type");
            this.articleSubType = jo.optInt("article_sub_type");
            this.articleUrl = jo.optString("article_url");
            this.articleAltUrl = jo.optString("article_alt_url");
            this.preloadWeb = jo.optInt("preload_web");
            this.mBanComment = jo.optInt("ban_comment") > 0;
            this.natantLevel = jo.optInt("natant_level");
            this.entityStyle = jo.optInt("entity_style");
            this.entityId = jo.optLong("entity_id");
            this.entityWord = jo.optString("entity_word");
            this.entityText = jo.optString("entity_text");
            this.tinyToutiaoUrl = jo.optString("tiny_toutiao_url");
            v0_3 = jo.optJSONArray("entity_mark");
            this.entityMarkJson = v0_3 != null ? v0_3.toString() : ((String) null);
            try {
                this.entityMark = parseEntityMark(v0_3);
            } catch (JSONException jsonException) {
                jsonException.printStackTrace();
            }
            this.entityFollowed = jo.optInt("entity_followed");
            this.entityScheme = jo.optString("entity_scheme");
            this.concernId = jo.optLong("concern_id");
            this.groupFlags = jo.optInt("group_flags");
            this.tcHeadText = jo.optString("tc_head_text");
            this.openUrl = jo.optString("open_url");
            this.outerSchema = jo.optString("outer_schema");
            this.openPageUrl = jo.optString("open_page_url");
            this.videoId = jo.optString("video_id");
            this.videoDuration = jo.optInt("video_duration");
            if (jo.has("user_like")) {
                this.userLike = jo.optBoolean("user_like");
            }

            if (jo.has("like_count")) {
                this.likeCount = jo.optInt("like_count");
            }

            try {
                v0_3 = jo.getJSONArray("ad_video_click_track_urls");
                if (v0_3 == null) {
                } else {
                    String[] v3 = new String[1];
                    this.adVideoClickTrackUrls = BaseAdsData.a(v0_3, v3);
                    this.adVideoClickTrackUrlsJson = v3[0];
                }
            } catch (JSONException v0_2) {
            }

            this.mediaName = jo.optString("media_name");
            this.isOriginal = jo.optBoolean("is_original");
            this.reason = jo.optString("reason");
        }

        if (jo.has("zzcomment")) {
            this.c(jo.optJSONArray("zzcomment"));
        }

        this.ao = new a();
        try {
            v0 = jo.optJSONObject("highlight");
            if (v0 == null) {
            } else {
                this.ao.title = parseEntityMark(v0.optJSONArray("title"));
                this.ao._abstract = parseEntityMark(v0.optJSONArray("abstract"));
            }
        } catch (Exception v0_1) {
        }

        this.ao.tip = jo.optInt("tip");
        this.ao.adId = jo.optLong("ad_id");
        this.ao.adLabel = jo.optString("ad_label");
        String[] v1 = new String[1];
        Object adTrackUrlList = jo.opt("ad_track_url_list");
        if (adTrackUrlList == null) {
            adTrackUrlList = jo.opt("ad_track_url");
        }

        if (adTrackUrlList == null) {
            adTrackUrlList = jo.opt("ad_track");
        }

        this.ao.adTrackUrl = BaseAdsData.a(adTrackUrlList, v1);
        this.ao.d = v1[0];
        adTrackUrlList = jo.opt("ad_click_track_url_list");
        if (adTrackUrlList == null) {
            adTrackUrlList = jo.opt("ad_click_track_url");
        }

        this.ao.adClickTrackUrlList = BaseAdsData.a(adTrackUrlList, v1);
        this.ao.f = v1[0];
        this.ao.goDetailCount = jo.optLong("go_detail_count", 0);
        this.ao.label = jo.optString("label");
        this.ao.labelStyle = jo.optInt("label_style");
        if (BaseAppData.inst().useOldParseJsonStyle()) {
            if (jo.has("reback_flag")) {
                this.rebackFlag = jo.optInt("reback_flag");
            }
            if (jo.has("tags")) {
                try {
                    v0_3 = jo.optJSONArray("tags");
                    this.tags = new ArrayList();
                    int v1_1 = v0_3.length();
                    while (true) {
                        if (v2 >= v1_1) {
                            break;
                        }

                        String v3_1 = v0_3.optString(v2);
                        if (v3_1 != null) {
                            this.tags.add(v3_1);
                        }

                        ++v2;
                        continue;
                    }
                } catch (Exception v0_1) {
                }


            }

            if (jo.has("wap_headers")) {
                try {
                    this.wapHeaders = jo.optJSONObject("wap_headers");
                } catch (Exception v0_1) {
                }
            }
        }

        JSONObject videoDetailInfoJO = jo.optJSONObject("video_detail_info");
        if (videoDetailInfoJO != null) {
            this.parseVideoDetailInfo(videoDetailInfoJO);
            this.videoDetailInfo = videoDetailInfoJO.toString();
        }
        String videoPlayInfo = jo.optString("video_play_info");
        if (!TextUtils.isEmpty(videoPlayInfo)) {
            this.videoPlayInfo = Pair.create(videoPlayInfo, Long.valueOf(SystemClock.elapsedRealtime()));
        }
    }

    public final boolean parseSpecialField(String key, JSONObject jo) {
        JSONArray v1_2;
        JSONObject v1;
        List v3 = null;
        boolean v0 = true;
        if ("media_info".equals(key)) {
            v1 = jo.optJSONObject("media_info");
            this.mediaInfo = MediaInfo.fromJO(v1);
            if (this.mediaInfo == null) {
                return v0;
            }

            this.mediaInfoJson = v1.toString();
            return v0;
        }

        if ("image_list".equals(key)) {
            this.imageList = v3;
            try {
                this.parseImageList(jo.optJSONArray("image_list"));
            } catch (Exception v1_1) {
                Logger.v("Article", "parse image_list exception: " + v1_1);
            }

            return v0;
        }

        if ("comment".equals(key)) {
            this.commentJson = "";
            this.comment = ((Comment) null);
            try {
                v1 = jo.optJSONObject("comment");
                this.parseComment(v1);
                if (this.comment == null) {
                    return v0;
                }

                this.commentJson = v1.toString();
            } catch (Exception v1_1) {
            }

            return v0;
        }

        if ("comments".equals(key)) {
            try {
                this.setCommentsJSONArray(jo.optJSONArray("comments"));
            } catch (Exception v1_1) {
                Logger.throwExceptionInDebug(((Throwable) v1_1));
            }

            return v0;
        }

        if ("zzcomment".equals(key)) {
            try {
                this.c(jo.optJSONArray("zzcomment"));
            } catch (Exception v1_1) {
                Logger.throwExceptionInDebug(((Throwable) v1_1));
            }

            return v0;
        }

        if ("large_image_list".equals(key)) {
            this.largeImageList = ((ImageInfo) v3);
            try {
                v1_2 = jo.optJSONArray("large_image_list");
                if (v1_2.length() <= 0) {
                    return v0;
                }

                this.largeImageList = ImageInfo.fromJson(v1_2.getJSONObject(0), true);
                if (this.largeImageList == null) {
                    return v0;
                }

                this.largeImageJson = v1_2.toString();
            } catch (Exception v1_1) {
            }

            return v0;
        }

        if ("middle_image".equals(key)) {
            this.middleImageJson = "";
            this.middleImage = ((ImageInfo) null);
            try {
                v1 = jo.optJSONObject("middle_image");
                this.middleImage = ImageInfo.fromJson(v1, false);
                if (this.middleImage == null) {
                    return v0;
                }

                this.middleImageJson = v1.toString();
            } catch (Exception v1_1) {
            }

            return v0;
        }

        if ("entity_mark".equals(key)) {
            v1_2 = jo.optJSONArray("entity_mark");
            this.entityMarkJson = v1_2 != null ? v1_2.toString() : ((String) null);
            try {
                this.entityMark = parseEntityMark(v1_2);
            } catch (JSONException v1_3) {
                v1_3.printStackTrace();
            }

            return v0;
        }

        if ("ad_video_click_track_urls".equals(key)) {
            try {
                v1_2 = jo.getJSONArray("ad_video_click_track_urls");
                if (v1_2 == null) {
                    return v0;
                }

                String[] v2 = new String[1];
                this.adVideoClickTrackUrls = BaseAdsData.a(v1_2, v2);
                this.adVideoClickTrackUrlsJson = v2[0];
            } catch (JSONException v1_3) {
            }

            return v0;
        }

        if ("user_info".equals(key)) {
            v1 = jo.optJSONObject("user_info");
            this.userInfo = UgcUser.extractFromUserInfoJson(v1);
            if (this.userInfo == null) {
                return v0;
            }

            this.userInfoJson = v1.toString();
        } else {
            v0 = false;
        }

        return v0;
    }

    public final boolean hasArticleUrl() {
        return this.articleType == 1
                && !android.support.design.a.isTextEmpty(this.articleUrl);
    }

    public final void setCommentsJSONArray(JSONArray commentJA) {
        if (commentJA != null) {
            try {
                if (commentJA.length() <= 0) {
                    return;
                }
                ArrayList<Comment> commentList = new ArrayList();
                for (int i = 0; i < commentJA.length(); ++i) {
                    Comment comment = parseCommentJO(commentJA.getJSONObject(i));
                    if (comment != null) {
                        commentList.add(comment);
                    }
                }
                if (commentList.size() <= 0) {
                    return;
                }
                this.comments = commentList;
                this.commentsJson = commentJA.toString();
            } catch (Exception exception) {
                Logger.throwExceptionInDebug(exception);
            }
        }
    }

    public final void parseVideoDetailInfo(JSONObject arg4) {
        if (arg4 != null) {
            this.videoId = arg4.optString("video_id", this.videoId);
            this.directPlay = AbsApiThread.optBoolean(arg4, "direct_play", false);
            this.showPgcSubscribe = AbsApiThread.optBoolean(arg4, "show_pgc_subscribe", false);
            this.videoWatchCount = arg4.optInt("video_watch_count");
            this.videoSubjectId = arg4.optLong("video_subject_id");
            this.videoType = arg4.optInt("video_type");
            try {
                this.mLoadingCoverImageInfo = ImageInfo.fromJson(arg4.optJSONObject("detail_video_large_image"), true);
            } catch (Exception v0) {
            }

            if (this.mLoadingCoverImageInfo == null && this.largeImageList != null) {
                this.mLoadingCoverImageInfo = this.largeImageList;
            }

            this.videoPreloadingFlag = arg4.optInt("video_preloading_flag");
        }
    }

    public final void c(JSONArray arg4) {
        if (arg4 != null) {
            try {
                if (arg4.length() <= 0) {
                    return;
                }

                ArrayList v1 = new ArrayList();
                int v0_1;
                for (v0_1 = 0; v0_1 < arg4.length(); ++v0_1) {
                    Comment v2 = parseCommentJO(arg4.getJSONObject(v0_1));
                    if (v2 != null) {
                        v1.add(v2);
                    }
                }

                if (v1.size() <= 0) {
                    return;
                }

                this.zzcomment = ((List) v1);
                this.zzcommentJson = arg4.toString();
            } catch (Exception v0) {
                Logger.throwExceptionInDebug(((Throwable) v0));
            }
        }
    }

    public final void parseComment(JSONObject jo) throws JSONException {
        this.comment = parseCommentJO(jo);
    }

    public final boolean c() {
        return this.hasArticleUrl() && (this.groupFlags & 16) > 0 && (!android.support.design.a.isTextEmpty(this.tcHeadText));
    }

    public final void parseImageList(JSONArray arg3) throws JSONException {
        ArrayList v0 = ImageInfo.optImageList(arg3, false);
        if (v0 != null && !((List) v0).isEmpty()) {
            this.imageList1 = arg3.toString();
            this.imageList = ((List) v0);
        }
    }

    public final boolean d() {
        return !(this.articleType != 1 || this.articleSubType != 1);
    }

    public final void onFinishParse(JSONObject jsonObject) {
        this.initWithJO(jsonObject);
    }

    public final boolean e() {
        return this.hasArticleUrl() && (this.groupFlags & 128) > 0;
    }

    private static Comment parseCommentJO(JSONObject jo) {
        Comment comment = new Comment();
        comment.commentId = jo.optLong("comment_id", 0);
        if (comment.commentId <= 0) {
            return null;
        } else {
            comment.formFriend = jo.optInt("from_friend", 0) > 0;
            comment.createTime = jo.optLong("create_time");
            comment.userId = jo.optLong("user_id");
            comment.userName = jo.optString("screen_name");
            comment.avatarUrl = jo.optString("avatar_url");
            comment.text = jo.optString("text");
            comment.diggCount = jo.optInt("digg_count");
            comment.buryCount = jo.optInt("bury_count");
            comment.userDigg = jo.optInt("user_digg") > 0;
            comment.userBury = jo.optInt("user_bury") > 0;
            comment.commentId = jo.optLong("comment_id");
            comment.replyCount = jo.optInt("reply_count");
            comment.userId = jo.optLong("user_id");
            comment.avatarUrl = jo.optString("avatar_url");
            comment.userName = jo.optString("user_name");
            comment.userVerified = jo.optBoolean("user_verified");
            comment.spipeUser = new SpipeUser(comment.userId);
            if (jo.has("is_blocked")) {
                comment.spipeUser.setIsBlocked(AbsApiThread.optBoolean(jo, "is_blocked", false));
            }

            if (jo.has("is_blocking")) {
                comment.spipeUser.setIsBlocking(AbsApiThread.optBoolean(jo, "is_blocking", false));
            }

            JSONObject mediaInfo = jo.optJSONObject("media_info");
            if (mediaInfo != null) {
                comment.mediaInfoJson = mediaInfo.toString();
                comment.mediaName = mediaInfo.optString("name");
                comment.mediaId = mediaInfo.optString("media_id");
                if (!android.support.design.a.isTextEmpty(comment.mediaId)) {
                    comment.url = "http://www.toutiao.com/m" + comment.mediaId + "/";
                }
            }
            return comment;
        }
    }

    public final boolean f() {
        return (!this.hasArticleUrl()) && (!this.isDetailLoaded);
    }

    public final boolean disableScrollOver() {
        return (this.groupFlags & 28672) != 0 || this.natantLevel == 2;
    }

    public String getItemKey() {
        return this.itemId > 0 ? "i_" + this.itemId : "g_" + this.groupId;
    }

    public String getShareUrl() {
        return this.shareUrl;
    }

    public final boolean h() {
        return this.hasVideo || (this.groupFlags & 1) > 0;
    }

    public final boolean i() {
        return (this.groupFlags & 32) > 0;
    }

    public final int getCommentMode() {
        if ((this.groupFlags & 4096) > 0) {//no_comments_mode
            return 1;
        } else if ((this.groupFlags & 8192) > 0) {//hide_mode
            return 2;
        } else {
            return 0;
        }
    }

    public final boolean k() {
        return (this.groupFlags & 32768) > 0;
    }

    public final int sp() {
        return (this.groupFlags & 65536) > 0 ? 1 : 0;
    }

    public final boolean m() {
        return (this.groupFlags & 131072) > 0 && this.articleType == 0;
    }

    public final boolean n() {
        return (this.groupFlags & 131072) > 0 && this.articleType == 1;
    }

    public final boolean o() {
        return this.y != null && this.y.size() > 0;
    }

    public final boolean isLiveVideo() {
        return this.videoType == 1;
    }

    public final boolean shouldPreloadVideo() {
        return VideoCacheController.SHOULD_PRELOAD
                ? true
                : this.videoPreloadingFlag > 0;
    }

    public final ImageInfo getMiddleImage() {
        return this.middleImage;
    }

    public final ImageInfo s() {
        return this.largeImageList;
    }

    public final List t() {
        return this.imageList;
    }

    public final String getTitle() {
        return this.title;
    }

    public final int v() {
        return BaseAppData.inst().useImageQqShare();
    }

    public final String w() {
        return !this.m() || !this.o() ? this._abstract : ((VideoAlbumInfo) this.y.get(0)).url;
    }

    public final String getVideoId() {
        return this.videoId;
    }

    public final String getMediaName() {
        return this.mediaName;
    }

    public final long getGroupId() {
        return this.groupId;
    }
}

